package com.example.blueconn.fragment.bl;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.blueconn.Constant;
import com.example.blueconn.R;
import com.example.blueconn.data.FxData;
import com.example.blueconn.databinding.FragmentBlSelectBinding;
import com.example.blueconn.databinding.FragmentViewParamBinding;
import com.example.blueconn.manager.DataMgr;
import com.example.blueconn.manager.FastBleManager;
import com.example.blueconn.manager.PreferenceManager;
import com.example.blueconn.utils.SPLightUtils;
import com.example.blueconn.utils.SPUtils;

import java.util.Map;

/**
 * Created by zhudongao
 * Desc
 * Date 4/5/21
 */

public class BLViewParamFragment extends Fragment{
    private FragmentViewParamBinding dataBinding;
    private BlRecyclerAdapter adapter;

    public BLViewParamFragment() {
        // Required empty public constructor
    }

    public static BLViewParamFragment newInstance() {
        return new BLViewParamFragment();
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_view_param, container, false);
        initView();
        return dataBinding.getRoot();
    }

    private void initView() {
        Map<Integer, FxData> lightMap = SPLightUtils.getMap(Constant.LIGHT_PARAMS_KEY);
        Map<Integer, FxData> lightFxMap = DataMgr.getLightFxMap();
        Map<Integer, FxData> tempMap = SPUtils.getMap(Constant.TEMP_PARAMS_KEY);

        Log.i("ceshimap", "lightMap: " + lightMap.toString());
        Log.i("ceshimap", "tempMap: " + tempMap.toString());

        dataBinding.recycler.setLayoutManager(new LinearLayoutManager(getContext()));
        BlViewParamAdapter adapter = new BlViewParamAdapter();

        dataBinding.recycler.setAdapter(adapter);
    }
}
